package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.tencent.mmkv.MMKV;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.response.PaymentNotesBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.math.BigDecimal;
import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023/12/25  14:49
 * @Description:物业缴费的缴费记录适配器
 */
public class PaymentNotesAdapter extends BaseQuickAdapter<PaymentNotesBean, BaseViewHolder> {

    public PaymentNotesAdapter(int layoutResId, @Nullable List<PaymentNotesBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PaymentNotesBean paymentNotesBean) {

        if (paymentNotesBean != null) {

            String payTypeTextString = paymentNotesBean.getReceiptTypeInfo();//线上和线下需要判断下。但是支付内容的名称是给定的。
            String receiptTypeInfo = paymentNotesBean.getPayTypeInfo();//缴费方式1支付宝2微信3线下

            //2018年03月28日.修改为全部文字给定
            /*if (TextUtils.equals(payType,"1")){//支付宝支付
                payTypeTextString="在线缴费";
                //payTypeName = "支付宝支付";
            }else if(TextUtils.equals(payType,"2")){//微信支付
                payTypeTextString="在线缴费";
                //payTypeName = "微信支付";
            }else if(TextUtils.equals(payType,"3")){//线下缴费
                payTypeTextString="线下缴费";
                //待定??也可用有卡或者现金或者优惠券。
            }*/

            String receiptNo = paymentNotesBean.getReceiptNo();//付款单号
            String payTime = paymentNotesBean.getPayTime();//缴费时间

            //费用名称：
            String paymentName = paymentNotesBean.getPaymentName();

            BigDecimal payAmount = paymentNotesBean.getTotalAmount();
            BigDecimal payAmountFormat = CommUtils.formatComma2BigDecimal(payAmount);

            //将来要做非空判断
            baseViewHolder.setText(R.id.textViewpayonoroffline, TextUtils.isEmpty(payTypeTextString) ? "" : payTypeTextString);
            //费用名称：
            baseViewHolder.setText(R.id.textviewpayinfoname, TextUtils.isEmpty(paymentName) ? "" : paymentName);//费用名称
            baseViewHolder.setText(R.id.textvieworder, TextUtils.isEmpty(receiptNo) ? "" : receiptNo);//订单编号
            baseViewHolder.setText(R.id.textpaytime, TextUtils.isEmpty(payTime) ? "" : payTime);//付款时间
            baseViewHolder.setText(R.id.textpaytype, TextUtils.isEmpty(receiptTypeInfo) ? "" : receiptTypeInfo);//支付方式名称:微信，支付宝，其他
            //helper.setText(R.id.textamount,TextUtils.isEmpty(amountFinal)?"":amountFinal);//付款金额
//            baseViewHolder.setText(R.id.textamount, _sessionErrorActivity.getCurrencySymbol() + payAmountFormat.toString());//付款金额
            baseViewHolder.setText(R.id.textamount, MMKV.defaultMMKV().decodeString(ConstantSign.P_CURRENCYSYMBOL, StringUtils.getString(R.string.yangjiaocurrencysymbol)) + payAmountFormat.toString());//付款金额


        }

    }
}
